<admintpl file="header" />
<head>
    <meta charset="UTF-8">
    <title>类型列表</title>
    <style>
        .bc-col-0 {
            background-color: #f7ecb5;
        }
        .bc-col-1 {
            background-color: #ffffe9;
        }
    </style>
</head>
<body>

    <div class="wrap js-check-wrap">
        <ul class="nav nav-tabs">
            <li class="active"><a>分类列表</a></li>
            <li><a href="{:U('Label/CategoryAdmin/category_edit')}">新建分类</a></li>
        </ul>

        <form class="well form-search" method="post" action="{:U('CategoryAdmin/category_list')}">&nbsp;
            分类：
            <select name="type">
                <option value="0">全部</option>
                <?php foreach($type_list as $k => $v) { ?>
                    <option value="{$k}" {$type == $k ? "selected" : ''}>{$v}</option>
                <?php }?>
            </select>
            <input type="submit" class="btn btn-primary" value="搜索" />
            <a class="btn btn-danger" href="{:U('CategoryAdmin/category_list')}">清空</a>
        </form>

        <table class="table table-hover table-bordered table-list">
            <thead>
            <tr>
                <th width="50">排序</th>
                <th width="50">ID</th>
                <th width="150">类型名称</th>
                <th width="150">所属分类</th>
                <th width="70">状态</th>
                <th width="70">操作</th>
            </tr>
            </thead>
            <php>
                $status     = array('0' => "隐藏", '1' => "显示");
                $change     = 0;
                $this_type  = $categorys[0]['type'];
            </php>
            <foreach name="categorys" item="vo">
                <php>
                    if ($this_type != $vo['type']) {
                        $change     = $change == 1 ? 0 : 1;
                        $this_type  = $vo['type'];
                    }
                </php>
                <tr class="bc-col-{$change}">
                    <td><input data-id="{$vo.id}" class="input input-order" type="text" size="5" value="{$vo.sort}"></td>
                    <td><b>{$vo.id}</b></td>
                    <td>{$vo.name}</td>
                    <td>{$type_list[$vo['type']]}</td>
                    <td>{$status[$vo['status']]}</td>
                    <td>
                        <a href="{:U('CategoryAdmin/category_edit', ['id' => $vo['id']])}">{:L('EDIT')}</a> |
                        <a href="{:U('CategoryAdmin/category_edit', array('id' => $vo['id'], 'delete' => 1))}">{:L('DELETE')}</a>
                    </td>
                </tr>
            </foreach>
        </table>
    </div>
    <script src="__PUBLIC__/js/common.js"></script>
    <script>
        $(document).ready(function () {
            $('body').delegate('.input-order', 'change', function () {
                var order 	= $(this).val();
                var id 		= $(this).attr('data-id');
                $.get("{:U('Label/CategoryAdmin/change_category_sort')}", {id : id, order : order}, function (data) {
                    if (data.status) {
                        window.location.reload();
                    }
                })
            })
        })
    </script>
</body>
</html>